A procedure is able to
call other procedures from inside it. It is also able to call
itself from inside it. This is known as Recursion.
Procedure Recurse()
Recurse
End
Proc
This procedure repeatedly
calls itself. This, however, would cause an infinite loop because
it would just keep calling itself and would never stop.
In order to prevent this
from happening recursive procedures need to be able to keep track
of how many times they have been called.
Procedure Recurse(n)
if n>0
Recurse(n-1)
end
if
This would only call the
procedure n times because each time it is called the value of
n is reduced. Once n becomes less than or equal to 0, the procedure
is no longer called and termination of all the called procedures
would begin.